package mvc.tubolar;

import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JPanel;

import mvc.ControllerMouse3D;
import gui.Block;
import gui.SliderPanel;

public class TubolarBlock extends Block {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private TubolarModel model;
	
	public TubolarBlock(String title, TubolarModel surface) {
		super(title);
		this.model = surface;

		initSwing();
	}
	
	private void initSwing() {
		TubolarView3D canvas = new TubolarView3D(this.model, new Dimension(500,500));
		addView(canvas);
		
		ControllerMouse3D controller = new ControllerMouse3D(canvas);
		canvas.addMouseKeybController(controller);
		
		model.addView(canvas);
		
		//aggiungi la bezier per regolare il diametro del tubo
	}
	
	@Override
	protected void initControls() {
		super.initControls();
		
		JPanel p = new JPanel();
		p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
	
		TubolarPanelController controller = new TubolarPanelController(model);
		
		SliderPanel s = new SliderPanel("Radius", 1, 20, 5, controller, "Radius");
		controller.setRadius(5, true);
		p.add(s);

		s = new SliderPanel("Diameter", 1, 20, 10, controller, "DiameterPoints");
		controller.setDiameterPoints(10, true);
		p.add(s);

		s = new SliderPanel("Sampling rate", 1, 20, 5, controller, "U");
		controller.setU(5, true);
		p.add(s);
	

		controlWindow.add(p);
		controlWindow.setLocation(1000, 500);
	}

}
